﻿// -------------------------------------------------------------------------
//    @FileName         :    NFLoginUtil.cpp
//    @Author           :    gaoyi
//    @Date             :    24-8-28
//    @Email            :    445267987@qq.com
//    @Module           :    NFLoginUtil
//
// -------------------------------------------------------------------------

#include "NFLoginUtil.h"

#include <NFPlayer.h>
#include <NFTransGetRole.h>

int NFLoginUtil::SendTransGetRole(NFSession* pSession, const proto_ff::Proto_CSGetRoleReq &oCSGetRoleReq)
{
    CHECK_NULL(0, pSession);
    NFTransGetRole *pTrans = NFTransGetRole::CreateTrans();
    CHECK_EXPR(pTrans, ERR_TRANS_RUNED_TOO_MUCH, "Create GetRole Trans Failed!UsedItem:{}", NFTransGetRole::GetStaticUsedCount());

    int iRetCode = pTrans->Init(pSession, proto_ff::E_CS_GETROLE_REQ, 0);
    CHECK_ERR_AND_FIN_TRANS(iRetCode, pTrans, "NFTransGetRole::Init Failed");
    iRetCode = pTrans->ProcessCSMsgReq(&oCSGetRoleReq);
    CHECK_ERR_AND_FIN_TRANS(iRetCode, pTrans, "NFTransGetRole::ProcessCSMsgReq Failed");
    return 0;
}

int NFLoginUtil::ServerLoginRole(NFSession* pSession, uint64_t roleId)
{
    CHECK_NULL(0, pSession);
    proto_ff::Proto_CSGetRoleReq req;
    req.set_role_id(roleId);
    return SendTransGetRole(pSession, req);
}
